import "./storage.dart";

class UserServices {
  
  static dynamic _userData = {};

  // 初始化：从SharedPreferences加载用户数据
  static Future<void> init() async {
    final userInfo = await Storage.getData("userinfo");
    if(userInfo != null){
      _userData = userInfo;
    }

  }

  // 同步获取用户数据
  static dynamic getUserDataSync() => _userData;
// 保存用户数据
  static Future<void> saveUserData(dynamic userData) async {
    await Storage.setData('userinfo', userData);
    _userData = userData;
  }

  // 清除用户数据
  static Future<void> clearUserData() async {
    await Storage.removeData('userinfo');
    _userData = null;
  }
}
